<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <p>用户名<span></span></p>
        <p>密码<span></span></p>
    </div>
    <script>
        function formatSearch( str ) {
            str = str.substr(1);
            var arr = str.split("&");
            var obj = {} ;
            arr.forEach( function ( item ){
                var newArr = item.split("=") ; 
                obj[newArr[0]] = newArr[1] ; 
            });
            return obj ; 
        }
        var str = window.location.search ;
        var obj = formatSearch(str) ; 
        var i = 0 ;
        for( var key in obj ){
            document.querySelectorAll("div p span")[i].innerHTML = obj[key];
            i ++ ; 
        }
    </script>
</body>
</html>